package com.itwenke.springbootdemo.knife4j.admin;

import com.itwenke.springbootdemo.knife4j.dto.UserInfoReqDTO;
import com.itwenke.springbootdemo.knife4j.dto.UserInfoRespDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "测试控制器", tags = "测试API")
@RestController
@RequestMapping(path = {"api/test"})
public class TestController {

    @ApiOperation("打招呼")
    @GetMapping(path = "/hi")
    public String hi(@ApiParam(value = "姓名", required = true) @RequestParam String name) {
        return "hi " + name;
    }

    @ApiOperation("查询用户")
    @GetMapping(path = "/query")
    public UserInfoRespDTO query(UserInfoReqDTO reqDTO) {
        UserInfoRespDTO respDTO = new UserInfoRespDTO();
        respDTO.setUserId(1L);
        respDTO.setUserName(reqDTO.getUserName());
        respDTO.setRole("admin");
        return respDTO;
    }
}
